#ifndef _GPS_CTRL_H
#define _GPS_CTRL_H

#include "gps.h"

#ifdef __cplusplus
extern "C"{
#endif

/*
 */

typedef enum tag_gps_status {
	gpsctrl_valid_set = 0,

	gpsctrl_invalid_set,
	gpsctrl_invalid_dev,
	gpsctrl_unknown,
} gps_status_t;

struct gpsctrl_object_t
{
//    char mountpoint[101];
    char port[32]; /* in my /etc/services 16 was the longest */
    gps_status_t status;

    double latitude;
    double longitude;
    double height;

};

struct fixsource_t
/* describe a data source */
{
    char *spec;		/* pointer to actual storage */
    char *server;
    char *port;
    /*@null@*/char *device;
};

typedef enum tag_gps_ret {
    gps_ret_ok = 0,

    gps_ret_nok,
    gps_open_fail,
    gps_select_fail,
    gps_select_timeout,
    gps_read_fail,
    gps_decode_fail,
    gps_read_nodata,
    gps_fopen_fail,
    gps_fputc_fail,
    gps_fflush_fail,
    gps_dev_noexist,

} gps_ret_t;

#define  debug_dump_buffer(num, str)  {                                \
    if( (num) > 0 )                                                    \
    {                                                                  \
        int32_t pst = 0;                                               \
        printf("DUMP BIN(%d): ", num);                                 \
        for( ; pst < num - 1; ++pst )                                  \
            printf("0x%02X,", *((unsigned char*)str + pst));           \
        printf("0x%02X\n", *((unsigned char*)str + num - 1));          \
    }                                                                  \
}

#define LIBGPS_DEBUG

#ifdef LIBGPS_DEBUG
#define DEBUG_NONE	0	/* no debug level */
#define DEBUG_CALLS	1	/* shallowest debug level */
#define DEBUG_JSON	5	/* minimum level for verbose JSON debugging */
#define libgps_debug_trace(args) (void) libgps_trace args
//extern int libgps_debuglevel;
//extern void libgps_dump_state(struct gps_data_t *);
#else
#define libgps_debug_trace(args) /*@i1@*/do { } while (0)
#endif /* LIBGPS_DEBUG */

gps_ret_t get_gps_status(uint8_t gps_addr, uint32_t entry, uint8_t *value);

gps_ret_t initGpsCom();

extern void gpsd_source_spec(/*@null@*/const char *fromstring,
			     /*@out@*/struct fixsource_t *source);

#ifdef __cplusplus
}
#endif


#endif //_GPS_CTRL_H
